// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

  // loading 预制体
  @property(cc.Prefab)
  m_LoadingPrefab = null

  // 复制loading预制体
  @property
  m_Loading = null

  // 获取loading 脚本
  @property
  m_Loading2 = null

  @property(cc.Node)
  m_Background = null

  @property(cc.Node)
  m_Logo = null

  onLoad() {
    this.m_Loading = cc.instantiate(this.m_LoadingPrefab);
    this.m_Loading.y = -160
    this.m_Background.addChild(this.m_Loading)
    console.log(this.m_Loading.getComponents(cc.Sprite))
    this.m_Loading2 = this.m_Loading.getComponent('loading')
    this.m_Loading2.setProgress(1)
    this.m_Loading2.callbackFunction = function () {
      this.m_Logo.active = false
      // 下面两者都可以使用
      this.m_Loading.active = false
      // this.m_Loading2.node.active = false
    }.bind(this)
  }

  start() {

  }

  // update (dt) {}
}
